package com.yswy.app.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.obs.services.model.PutObjectResult;
import com.yswy.app.service.IpPlaceService;
import com.yswy.app.service.TheaterPlayAppService;
import com.yswy.common.utils.AlphanumComparator;
import com.yswy.common.utils.FileSuffix;
import com.yswy.common.utils.HuaWeiYunOBSUtil;
import com.yswy.common.utils.videoTpGif.FfmpegUtil;
import com.yswy.domain.entity.AppUser;
import com.yswy.theater.entity.TheaterPlay;
import com.yswy.theater.entity.TheaterPlayGather;
import com.yswy.theater.mapper.TheaterPlayMapper;
import com.yswy.theater.service.TheaterPlayBindTypeService;
import com.yswy.theater.service.TheaterPlayGatherService;
import com.yswy.theater.service.TheaterPlayService;
import com.yswy.theater.vo.req.AddTheaterPlay;
import com.yswy.theater.vo.req.ListTheaterPlayReqVo;
import com.yswy.theater.vo.res.TheaterPlayResVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.*;
import java.util.stream.Collectors;


@Slf4j
@Service
public class TheaterPlayAppServiceImpl extends ServiceImpl<TheaterPlayMapper, TheaterPlay>
        implements TheaterPlayAppService {

    @Autowired
    private TheaterPlayBindTypeService theaterPlayBindTypeService ;
    @Autowired
    private IpPlaceService ipPlaceService ;

    @Override
    public Page<TheaterPlayResVo> getTheaterPlayByType(ListTheaterPlayReqVo listTheaterPlayReqVo, AppUser appUser) {
        Boolean is = ipPlaceService.getIpPlaceStatus(appUser.getCreateIp());
        if (is){
            if (listTheaterPlayReqVo.getTypeId() == 1){
                listTheaterPlayReqVo.setTypeId(3L);
            }else {
                listTheaterPlayReqVo.setTypeId(4L);
            }
        }
        return theaterPlayBindTypeService.getTheaterPlayByType(listTheaterPlayReqVo , 0);
    }
}
